import { service } from "../http/request";

/**
 * 获取所有用户 除了自己
 *
 */
const getAllAdmins = (keyword) => {
  return service({
    method: 'get',
    url: '/system/admin/?keywords=' + keyword
  })
}

/**
 * 获取所有用户
 *
 */
const getAdmins = () => {
  return service({
    method: 'get',
    url: '/system/admin/getAdmins'
  })
}

/**
 * 删除用户
 */
const deleteAdmin = (id) => {
  return service({
    method: 'delete',
    url: '/system/admin/' + id
  })
}

/**
 * 更新用户
 */
const updateAdmin = (params) => {
  return service({
    method: 'put',
    url: '/system/admin/',
    data: params
  })
}

/**
 * 獲取所有角色
 */
const getAllRoles = () => {
  return service({
    method: 'get',
    url: '/system/admin/roles'
  })
}

/**
 * 更新用户角色
 */
const updateAdminRoles = (adminId,rids) => {
  return service({
    method: 'put',
    url: '/system/admin/role',
    data: {adminId,rids}
  })
}

/**
 * 更改密码
 */
const updatePass = (params) => {
  return service({
    method: 'put',
    url: '/admin/pass',
    data: params
  })
}

/**
 * 添加用户
 */
const createAdmin = (param) => {
  return service({
    method: 'post',
    url: '/system/admin/createAdmin',
    data: param
  })
}


export default {
  getAllAdmins,
  deleteAdmin,
  updateAdmin,
  getAllRoles,
  updateAdminRoles,
  getAdmins,
  updatePass,
  createAdmin
}
